//
//  AccountPriceCell.m
//  NtoccShipper
//
//  Created by mac on 2019/12/16.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "AccountPriceCell.h"
@interface AccountPriceCell ()<UITextFieldDelegate>
@property (nonatomic,strong) CJLabel *labTitle;

@end

@implementation AccountPriceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

- (void)setCellWithInfoTitle:(NSString *)strTitle withStrContent:(NSString *)str isEditor:(BOOL)editor{
    self.fieldContent.delegate = self;
    self.fieldContent.enabled = editor;
    self.labTitle.text = strTitle;
    self.fieldContent.text = str;
    
    if (editor) {
//        self.labTitle.textColor = [UIColor cjMainColorText];
        self.fieldContent.textColor = [UIColor cjMainTextColor];
    }else{
        self.fieldContent.textColor = [UIColor cjSubheadTextColor];
    }
}

- (void)setcellInfoWithDic:(NSDictionary *)dict{
//    NSDictionary *dic = @{
//        @"title":@"", // 左侧标题
//        @"content":@"",//右侧数量
//        @"isOtherFee":@"0",// 0 1 是
//        @"isEditor":@"0",// 0 1 是否编辑
//    @"isLoadAndDown":@"0",
//        @"isUnitsNum":@"0",//  装卸货的 单位是否 是件
//    };
    
    self.fieldContent.delegate = self;
    self.fieldContent.enabled = [dict[@"isEditor"] intValue] == 1 ? YES:NO ;
    self.labTitle.text = dict[@"title"];
    self.fieldContent.text = dict[@"content"];

    if ([dict[@"isEditor"] intValue] == 1 ) {
    //        self.labTitle.textColor = [UIColor cjMainColorText];
        self.fieldContent.enabled = YES;
        self.fieldContent.textColor = [UIColor cjMainTextColor];
    }else{
        self.fieldContent.textColor = [UIColor cjSubheadTextColor];
        self.fieldContent.enabled = NO;
    }
    //是否 装卸货
    if ([dict[@"isLoadAndDown"] intValue] == 1 ) {
        // 判断是否  件
        if ([dict[@"isUnitsNum"] intValue] == 1 ) {
            self.fieldContent.textFieldType = CJTextFieldStringTypeNumber;
            self.fieldContent.maxLength = 20;
        }else{
            self.fieldContent.textFieldType = CJTextFieldStringTypeThreeDecimalPlaces;
            self.fieldContent.maxLength = 16;
        }
        
    }else{
        self.fieldContent.textFieldType = CJTextFieldStringTypeMoneyValue;
        self.fieldContent.maxLength = CJTextLengthTen;
    }
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    if (self.blockEditor) {
        self.blockEditor(textField.text);
    }
}

@end
